package com.google.code.bankagregator.core.entityServices;

import com.google.code.bankagregator.dao.DepositDAO;
import com.google.code.bankagregator.entities.Deposit;

import javax.ejb.EJB;
import javax.ejb.Stateless;
import java.util.List;

/**
 * Deposit Service
 */
@Stateless
public class DepositService {

    @EJB
    DepositDAO depositDAO;

    public void createDeposit(Deposit deposit) {
        depositDAO.create(deposit);
    }

    public Deposit loadDeposit(int depositId) {
        Deposit deposit = null;
        deposit = depositDAO.getById(depositId);
        return deposit;
    }

    public void updateDeposit(Deposit deposit) {
        depositDAO.update(deposit);
    }

    public void deleteDeposit(int depositId) {
        depositDAO.delete(depositId);
    }

    public void deleteDeposit(Deposit deposit) {
        depositDAO.delete(deposit);
    }

    public List<Deposit> getAllDeposits() {
        List<Deposit> deposits = null;
        deposits = depositDAO.getAll();
        return deposits;
    }
}
